package Interfaces;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

import Jogo.Game;

public class InterfaceMenu {
	private JFrame frame;
	private JButton singlePlayerButton;
	private JButton multiPlayerButton;
	private JButton exitButton;
	private InterfaceFundo imagePanel;

	public InterfaceMenu() {
		criarMenu();
	}

	private void criarMenu() {
		frame = new JFrame("Menu");
		imagePanel = new InterfaceFundo();

		singlePlayerButton = new JButton("Single Player");
		multiPlayerButton = new JButton("MultiPlayer");
		exitButton = new JButton("Exit");

		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setResizable(false);
		frame.setSize(900, 600);
		frame.setLocation(100, 100);

		frame.add(imagePanel);

		imagePanel.setLayout(new FlowLayout());
		imagePanel.add(singlePlayerButton);
		imagePanel.add(multiPlayerButton);
		imagePanel.add(exitButton);

		singlePlayerButton.addActionListener(new Sentinela());
		multiPlayerButton.addActionListener(new Sentinela());
		exitButton.addActionListener(new Sentinela());

	}

	public class Sentinela implements ActionListener {
		@Override
		public void actionPerformed(ActionEvent e) {
			if (e.getSource() == singlePlayerButton) {
				new Game(1);

			} else if (e.getSource() == multiPlayerButton) {

			} else if (e.getSource() == exitButton) {
				System.exit(0);

			}

		}

	}

	public void init() {
		frame.setVisible(true);
	}

}
